﻿using MengLin.OOP.DesignPattern.CommandPattern.Barbecuer.Abstract;
using MengLin.OOP.DesignPattern.CommandPattern.Barbecuer.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.CommandPattern.Barbecuer
{
    class Program
    {
        static void Main(string[] args)
        {
            #region 传统写法
            //{
            //    OldBarbecuer barbecuer = new OldBarbecuer();

            //    barbecuer.BakeMutton();
            //    barbecuer.BakeMutton();
            //    barbecuer.BakeMutton();
            //    barbecuer.BakeChickenWing();
            //    barbecuer.BakeMutton();
            //    barbecuer.BakeMutton();
            //    barbecuer.BakeChickenWing();
            //}
            #endregion

            #region 命令模式第2版代码
            //{
            //    //开店前的准备
            //    Barbecuer barbecuer = new Barbecuer();//烤肉师傅
            //    AbstractCommand bakeMuttonCommand1 = new BakeMuttonCommand(barbecuer);//烤羊肉串命令
            //    AbstractCommand bakeMuttonCommand2 = new BakeMuttonCommand(barbecuer);//烤羊肉串命令
            //    AbstractCommand bakeChickenWingCommand1 = new BakeChickenWingCommand(barbecuer);//烤鸡翅命令
            //    Waiter waiter = new Waiter();//服务员

            //    //开门营业，顾客点菜，服务员下单点菜
            //    waiter.SetOrder(bakeMuttonCommand1);
                  //点菜完闭，通知厨房
            //    waiter.Notify();
            //    waiter.SetOrder(bakeMuttonCommand2);
                  //点菜完闭，通知厨房
            //    waiter.Notify();
            //    waiter.SetOrder(bakeChickenWingCommand1);
                  //点菜完闭，通知厨房
            //    waiter.Notify();
            //}
            #endregion

            #region 命令模式最终写法
            {
                //开店前的准备
                Barbecuer barbecuer = new Barbecuer();//烤肉师傅
                AbstractCommand bakeMuttonCommand1 = new BakeMuttonCommand(barbecuer);//烤羊肉串命令
                AbstractCommand bakeMuttonCommand2 = new BakeMuttonCommand(barbecuer);//烤羊肉串命令
                AbstractCommand bakeChickenWingCommand1 = new BakeChickenWingCommand(barbecuer);//烤鸡翅命令
                Waiter waiter = new Waiter();//服务员

                //开门营业，顾客点菜，服务员下单点菜
                waiter.SetOrder(bakeMuttonCommand1);
                waiter.SetOrder(bakeMuttonCommand2);
                waiter.SetOrder(bakeChickenWingCommand1);

                //点菜完闭，通知厨房
                waiter.Notify();
            }
            #endregion

            Console.Read();
        }
    }

    /// <summary>
    /// 烤肉串者
    /// </summary>
    public class OldBarbecuer
    {
        //烤羊肉
        public void BakeMutton()
        {
            Console.WriteLine("烤羊肉串!");
        }

        //烤鸡翅
        public void BakeChickenWing()
        {
            Console.WriteLine("烤鸡翅!");
        }
    }
}
